window.onload = function () { 
    //初始化消息列表
    initMessage();
}

async function initMessage() { 
    var sectionCard = document.getElementsByClassName("section-card")[0]
    const promise = await getData("/json/message.json")
    let messageList = promise.messageList
    messageList.forEach(element => {
        let $html = '<div class="card">'
            $html += '<img src='+ element.imageList[0]+ ' alt = ""/>'
            $html += '<div class = "tag-list">'
        let tagList = element.tagList
            for (let i = 0; i < tagList.length; i++) {
                $html += '<span class="tag">'+tagList[i]+'</span>'
            }
            $html += '</div>'
            $html += '<div class = "card-footer clearfix">'
            $html += '<a class="avatar">'
            $html += '<img src='+element.userAvatar+' alt = "">'
            $html += '<span>' + element.userName + '</span>'
            $html += '</a>'
            $html += '<div class="card-text">'
            $html += '<span class="ellipsis">联系电话：<strong>'+element.phone+'</strong></span>'
            $html += '<span class="ellipsis"> 联系地址： <strong>' + element.address + '</strong></span>'
            $html += '<span class="ellipsis"> 发布时间： <strong>' + element.createTime + '</strong></span>'
            $html += '</div> </div> </div>'
        sectionCard.innerHTML += $html
    });
}